package org.demo.mainframe.fx.handler;

import org.demo.mainframe.fx.MainPanel;

import javafx.event.EventHandler;
import javafx.event.EventType;
import javafx.scene.Parent;
import javafx.scene.input.MouseButton;
import javafx.scene.input.MouseEvent;

public class MainPanelMouseEventHandler implements EventHandler<MouseEvent> {
	private MainPanel p = null;

	public MainPanelMouseEventHandler(){}
	
	public MainPanelMouseEventHandler(MainPanel p) {
		this.p = p;
	}

	public void handle(MouseEvent mEvent) {
		EventType<? extends MouseEvent> eventType = mEvent.getEventType();
		int clickCount = mEvent.getClickCount();
		MouseButton button = mEvent.getButton();
		double screenX = mEvent.getScreenX();
		double screenY = mEvent.getScreenY();
		if (button == MouseButton.SECONDARY) {
			if(p==null){
				return;
			}
			p.showMenu(screenX,screenY);
		}

	}

}
